package forum.server.domain;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import org.junit.Before;
import org.junit.Test;

public class ModeratorTest {

	@Before
	public void setUp() throws Exception {
	}
	
	@Test
	public void modifyAnyMessage(){
		String header = "Basketball";
        PostContent postContent = new PostContent("Hello");
        LoggedInUser ru = new LoggedInUser("testSubject 0", "123abc");
        Post testPost = ru.addPost(header, postContent, 999);
        Moderator tModer = new Moderator("testModerator1", "1234");
        try{
            PostContent newPostContent = new PostContent("abc");
            tModer.modifyPost(testPost, newPostContent);
            assertEquals(testPost.getContent(), newPostContent);
            
        }
        catch(Exception e){
        	fail("Exception was thrown!");
        }
	}
	
	@Test
    public void deleteAnyPost() {
        String header = "Basketball";
        PostContent postContent = new PostContent("Hello");
        LoggedInUser ru = new LoggedInUser("testSubject 0", "123abc");
        Post testPost = ru.addPost(header, postContent, 999);
        Moderator moder = new Moderator("moderator 1", "123");
        try{
        	moder.deletePost(testPost);
        }
        catch (Exception e){
        	fail("Exception was thrown!");
        }
    }
}
